def bianli(root):
    if not root:
        return []
    else:
        layer = [[root], []]
        output = []
        count = 0
        while len(layer[count % 2]) > 0:
            now_layer = layer[count % 2]
            count += 1
            next_layer = []
            for item in now_layer:
                output.append(root.val)
                if item.left:
                    next_layer.append(item.left)
                if item.right:
                    next_layer.append(item.right)
            layer[count % 2] = next_layer
        return output